<!DOCTYPE html><html lang="zh-Hans"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta name="description" content="记一次字节面试"><meta name="keywords" content="面试 字节"><meta name="author" content="晟松"><meta name="copyright" content="晟松"><title>记一次字节面试 | 晟松</title><link rel="shortcut icon" href="/logo.png"><link rel="stylesheet" href="/css/index.css?version=1.9.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css?version=1.9.0"><meta name="format-detection" content="telephone=no"><meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="dns-prefetch" href="https://hm.baidu.com"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?c34d81d53341febe06a155941e2df16d";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();</script><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容:${query}"}},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  hexoVersion: '5.4.0'
} </script><meta name="generator" content="Hexo 5.4.0"></head><body><i class="fa fa-arrow-right" id="toggle-sidebar" aria-hidden="true"></i><div id="sidebar" data-display="true"><div class="toggle-sidebar-info text-center"><span data-toggle="切换文章详情">切换站点概览</span><hr></div><div class="sidebar-toc"><div class="sidebar-toc__title">目录</div><div class="sidebar-toc__progress"><span class="progress-notice">你已经读了</span><span class="progress-num">0</span><span class="progress-percentage">%</span><div class="sidebar-toc__progress-bar"></div></div><div class="sidebar-toc__content"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%B8%80%E9%9D%A2"><span class="toc-number">1.</span> <span class="toc-text">一面</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BA%8C%E9%9D%A2"><span class="toc-number">2.</span> <span class="toc-text">二面</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%80%BB%E7%BB%93"><span class="toc-number">3.</span> <span class="toc-text">总结</span></a></li></ol></div></div><div class="author-info hide"><div class="author-info__avatar text-center"><img src="/img/avatar.png"></div><div class="author-info__name text-center">晟松</div><div class="author-info__description text-center">晟松的博客</div><div class="follow-button"><a target="_blank" rel="noopener" href="https://gitee.com/cheng_song">Gitee</a></div><hr><div class="author-info-articles"><a class="author-info-articles__archives article-meta" href="/archives"><span class="pull-left">文章</span><span class="pull-right">52</span></a><a class="author-info-articles__tags article-meta" href="/tags"><span class="pull-left">标签</span><span class="pull-right">45</span></a></div></div></div><div id="content-outer"><div id="top-container" style="background-image: url(/img/blog-bg.jpg)"><div id="page-header"><span class="pull-left"> <a id="site-name" href="/">晟松</a></span><i class="fa fa-bars toggle-menu pull-right" aria-hidden="true"></i><span class="pull-right menus">   <a class="site-page" href="/">Home</a><a class="site-page" href="/archives">Archives</a><a class="site-page" href="/tags">Tags</a><a class="site-page" href="/categories">Categories</a></span><span class="pull-right"><a class="site-page social-icon search"><i class="fa fa-search"></i><span> 搜索</span></a></span></div><div id="post-info"><div id="post-title">记一次字节面试</div><div id="post-meta"><time class="post-meta__date"><i class="fa fa-calendar" aria-hidden="true"></i> 2021-04-26</time><div class="post-meta-wordcount"><span>字数总计: </span><span class="word-count">1.2k</span><span class="post-meta__separator">|</span><span>阅读时长: 4 分钟</span></div></div></div></div><div class="layout" id="content-inner"><article id="post"><div class="article-container" id="post-content"><p>第三次面试，还是稍微有了一些经验了</p>
<h4 id="一面"><a href="#一面" class="headerlink" title="一面"></a>一面</h4><p>记一下题吧：</p>
<ol>
<li><p>Web前端如何优化页面首屏时间</p>
</li>
<li><p>进程和线程的定义和区别</p>
</li>
<li><p>TCP断开连接为什么四次交互</p>
</li>
<li><p>用apply去实现bind</p>
</li>
<li><p>javascript对象深拷贝</p>
</li>
<li><p>css三种垂直居中的方式</p>
</li>
<li><p>路径总和给你二叉树的根节点 root 和一个表示目标和的整数 targetSum ，判断该树中是否存在 <strong>根节点到叶子节点</strong> 的路径，这条路径上所有节点值相加等于目标和 targetSum 。</p>
</li>
<li><p>最大连续子序列和求取数组中最大连续子序列和，例如给定数组为A={1， 3， -2， 4， -5}， 则最大连续子序列和为6，即1+3+（-2）+ 4 = 6。</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">preAdd</span>(<span class="params">arr</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> pre = <span class="number">0</span>,max = arr[<span class="number">0</span>];</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">let</span> i = <span class="number">0</span>;i&lt;arr.length;i++)&#123;</span><br><span class="line">        <span class="keyword">if</span>(pre&gt;<span class="number">0</span>)&#123;</span><br><span class="line">            pre+=arr[i]</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            pre = arr[i]</span><br><span class="line">        &#125;</span><br><span class="line">        max = <span class="built_in">Math</span>.max(pre,max)</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> max  </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>最短子数组和给定1个正整数数组array和1个正整数n，从array中寻找和值大于等于n的最短子数组。如果存在，则返回最短子数组长度；如果不存在返回0。例如：array = 1, 3, 4, 3, 9, 1, n = 12,那么子数组3, 9满足条件且长度最短为2。</p>
</li>
</ol>
<p>基本以算法题为主（至少一半），虽然前端用不到这些算法，但还是要以算法题为主，来进行一个面试筛选。毕竟人太多了</p>
<h4 id="二面"><a href="#二面" class="headerlink" title="二面"></a>二面</h4><p>虽然准备了许多，然后问了许多出乎意料的问题，答得也稀烂，最后基本没希望了</p>
<p>下面代码不确定正确</p>
<p>记一下问题吧：</p>
<ul>
<li><p>```js<br>下面代码输出的结果是什么？<br>var length = 10;<br>function fn() {<br> return this.length+1;<br>}<br>var obj = {<br> length: 5,<br> test1: function() {<br>  return fn();<br> }<br>};<br>obj.test2=fn;<br>//下面代码输出是什么<br>console.log(obj.test1())<br>console.log(fn()===obj.test2())</p>
<p>// 11 false</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- 手写es5继承</span><br><span class="line"></span><br><span class="line">- 实现一个repeat方法，要求如下：</span><br><span class="line"></span><br><span class="line">  ```js</span><br><span class="line">  // 需要实现的函数</span><br><span class="line">  function repeat (func, times, wait) &#123;&#125;，</span><br><span class="line">  </span><br><span class="line">  // 使下面调用代码能正常工作</span><br><span class="line">  const repeatFunc = repeat(console.log, 4, 3000);</span><br><span class="line">  repeatFunc(&quot;hello world&quot;);//会输出4次 helloworld, 每次间隔3秒</span><br><span class="line">  </span><br><span class="line">  function repeat (func, times, wait) &#123;</span><br><span class="line">      function refn(word)&#123;</span><br><span class="line">          if(times &gt;0)&#123;</span><br><span class="line">             setTimeout(()=&gt;&#123;</span><br><span class="line">              func.call(this,word)</span><br><span class="line">              times--;</span><br><span class="line">              refn(word)</span><br><span class="line">          </span><br><span class="line">              &#125;,wait)</span><br><span class="line">          &#125;</span><br><span class="line">      &#125;</span><br><span class="line">     return refn</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></li>
<li><p>假设有n个人，标号为1到n。 从第一个人开始计数，到第k个人则出列，随后从第k+1个人重新计数，到第k再出列….。 直至剩下最后一个人。问最后剩下的人的编号？</p>
<p>getNo(n,k)    </p>
<p>感觉这其实是进行一个规律的找寻</p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">Node</span>(<span class="params">i</span>)</span>&#123;</span><br><span class="line">    <span class="built_in">this</span>.val = i;</span><br><span class="line">    <span class="built_in">this</span>.next= <span class="literal">null</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">delNode</span>(<span class="params">node</span>)</span>&#123;</span><br><span class="line">    node.next = node.next.next</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getNo</span>(<span class="params">n,k</span>)</span>&#123;</span><br><span class="line">    <span class="keyword">let</span> head = <span class="keyword">new</span> Node(<span class="number">1</span>);</span><br><span class="line">    <span class="keyword">let</span> node = <span class="keyword">new</span> Node(<span class="number">2</span>);</span><br><span class="line">    head.next = node;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">let</span> i =<span class="number">3</span>;</span><br><span class="line">    <span class="keyword">while</span>(i&lt;=n)&#123;</span><br><span class="line">        <span class="keyword">let</span> next = <span class="keyword">new</span> Node(i);</span><br><span class="line">        node.next = next;</span><br><span class="line">        node = next;</span><br><span class="line">        i++;</span><br><span class="line">    &#125;</span><br><span class="line">    node.next = head</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">let</span> j = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">while</span>(head.next != head)&#123;</span><br><span class="line">        <span class="keyword">if</span>(j==k-<span class="number">1</span>)&#123;</span><br><span class="line">            j = <span class="number">1</span>;</span><br><span class="line">            <span class="comment">// 这里原来是错的</span></span><br><span class="line">            <span class="comment">// delNode(head.next)</span></span><br><span class="line">            delNode(head)</span><br><span class="line">            </span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            j++;</span><br><span class="line">            head = head.next</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> head.val</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">// Java正确版本</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Solution</span> </span>&#123;</span><br><span class="line">    public int <span class="function"><span class="title">lastRemaining</span>(<span class="params">int n, int m</span>)</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> f(n, m);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public int <span class="function"><span class="title">f</span>(<span class="params">int n, int m</span>)</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (n == <span class="number">1</span>) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        int x = f(n - <span class="number">1</span>, m);</span><br><span class="line">        <span class="keyword">return</span> (m + x) % n;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>设计一个正确统计SPA应用PV（person view）的SDK</p>
<ul>
<li>主要是spa应用url的切换可能会忽略，所以需要使用原生去监听url的切换（hash和history这两种）</li>
</ul>
</li>
<li><p>标题：输入电话号码时自动推荐出下一位合法的数字集</p>
<p>公司有10万名员工，每名员工都有一个座机号码。现在要在网页上实现一个“自动补位推荐” 的功能，问如何实现？</p>
<p>解释：</p>
<p>“自动补位推荐” 功能：有一个输入框，用户每输入一个数字，立马推荐出下一位合法的数字集合。比如只有 5789234、5623786、5633678三个电话号码，当第一位输入5时，立马推荐下一位有效数字集合[ 7, 6 ]，如果第二位输入6时，下一位有效数字集合为[2，3]….</p>
</li>
<li><p>在岛上有100只老虎和1只羊，老虎可以吃草，但他们更愿意吃羊。</p>
<p>假设：</p>
<p>A：每次只有一只老虎可以吃样，而且一旦他吃了羊，他自己就变成羊。</p>
<p>B：所有的老虎都是聪明而且完全理性的，他们的第一要务是生存。</p>
<p>问最后这只羊会不会被吃？如果是n只老虎和一只羊呢？</p>
<p>最后发现是动态规划的问题（单数虎就会吃，双数就不会吃）</p>
</li>
<li><p>扫码登录的一个流程如何实现（如果不用websocket呐）</p>
</li>
<li><p>怎么学前端的这些</p>
</li>
<li><p>vue的watcher有哪些（watch属性，数据的watch，computed，页面的watch这些）</p>
</li>
</ul>
<h4 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h4><p>我是傻逼。好多算法啊。人傻了</p>
</div></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">晟松</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://chengsong.info/2021/04/26/记一次字节面试/">https://chengsong.info/2021/04/26/记一次字节面试/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://chengsong.info">晟松</a>！</span></div></div><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E9%9D%A2%E8%AF%95-%E5%AD%97%E8%8A%82/">面试 字节</a></div><nav id="pagination"><div class="prev-post pull-left"><a href="/2021/05/16/%E5%8C%BA%E5%9D%97%E9%93%BE%E4%B8%AD%E5%90%84%E5%90%8D%E8%AF%8D%E8%A7%A3%E9%87%8A/"><i class="fa fa-chevron-left">  </i><span>区块链中各名词解释</span></a></div><div class="next-post pull-right"><a href="/2021/04/22/%E8%AE%B0%E4%B8%80%E4%B8%8B%E7%AC%AC%E4%BA%8C%E6%AC%A1%E9%9D%A2%E8%AF%95/"><span>记一下第二次面试</span><i class="fa fa-chevron-right"></i></a></div></nav></div></div><footer class="footer-bg" style="background-image: url(/img/blog-bg.jpg)"><div class="layout" id="footer"><div class="copyright">&copy;2020 - 2023 By 晟松</div><div class="framework-info"><span>驱动 - </span><a target="_blank" rel="noopener" href="http://hexo.io"><span>Hexo</span></a><span class="footer-separator">|</span><span>主题 - </span><a target="_blank" rel="noopener" href="https://github.com/Molunerfinn/hexo-theme-melody"><span>Melody</span></a></div><div class="icp"><a target="_blank" rel="noopener" href="http://www.beian.miit.gov.cn/"><span>湘ICP备2020021729号</span></a></div><div class="busuanzi"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span id="busuanzi_container_page_pv"><i class="fa fa-file"></i><span id="busuanzi_value_page_pv"></span><span></span></span></div></div></footer><i class="fa fa-arrow-up" id="go-up" aria-hidden="true"></i><script src="https://cdn.jsdelivr.net/npm/animejs@latest/anime.min.js"></script><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@latest/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-ui-pack@latest/velocity.ui.min.js"></script><script src="/js/utils.js?version=1.9.0"></script><script src="/js/fancybox.js?version=1.9.0"></script><script src="/js/sidebar.js?version=1.9.0"></script><script src="/js/copy.js?version=1.9.0"></script><script src="/js/fireworks.js?version=1.9.0"></script><script src="/js/transition.js?version=1.9.0"></script><script src="/js/scroll.js?version=1.9.0"></script><script src="/js/head.js?version=1.9.0"></script><script src="/js/search/local-search.js"></script><script>if(/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
  $('#nav').addClass('is-mobile')
  $('footer').addClass('is-mobile')
  $('#top-container').addClass('is-mobile')
}</script><div class="search-dialog" id="local-search"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章"></div></div></div><hr><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fa fa-times"></i></span></div><div class="search-mask"></div></body></html>